package com.jia.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jia.dto.admin.CouponsDto;
import com.jia.entity.Coupons;
import com.jia.entity.User;
import com.jia.service.CouponsService;
import com.jia.mapper.CouponsMapper;
import com.jia.vo.admin.CouponsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 贾天旺
* @description 针对表【t_coupons】的数据库操作Service实现
* @createDate 2024-04-25 20:51:56
*/
@Service
public class CouponsServiceImpl extends ServiceImpl<CouponsMapper, Coupons>
    implements CouponsService{

    @Autowired
    private CouponsMapper couponsMapper;

    @Override
    public Page<CouponsVo> COUPONS_VO_PAGE(int page, int limit, CouponsDto couponsDto) {
        return couponsMapper.COUPONS_VO_PAGE(new Page<CouponsVo>(page,limit),couponsDto);
    }

    @Override
    public void updateState(int id) {
        Coupons coupons = this.getById(id);
        if (ObjectUtil.isNotEmpty(coupons)) {
            coupons.setState(coupons.getState() == 1 ? 0 : 1);
            this.updateById(coupons);
        }
    }

    @Override
    public Page<CouponsVo> COUPONSUser_VO_PAGE(int page, int limit, CouponsDto couponsDto) {
        return couponsMapper.COUPONSUser_VO_PAGE(new Page<CouponsVo>(page,limit),couponsDto);
    }
}




